package com.zhongxi.guoyuan.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import com.zhongxi.guoyuan.R;
import com.zhongxi.guoyuan.application.MyApplication;
import com.zhongxi.guoyuan.base.BaseFragment;
import com.zhongxi.guoyuan.view.seller.SellerBeautifulStoreLoginActivity;
import com.zhongxi.guoyuan.view.seller.SellerBeautifulStoreOrderActivity;
import com.zhongxi.guoyuan.view.seller.SellerCoinStoreLoginActivity;
import com.zhongxi.guoyuan.view.seller.SellerCoinStoreOrderActivity;
import com.zhongxi.guoyuan.view.seller.SellerManagerLoginActivity;
import com.zhongxi.guoyuan.view.seller.SellerManagerOrderActivity;

public class SellerFragment extends BaseFragment implements View.OnClickListener {

    private RelativeLayout relaAllCenter;
    private RelativeLayout relaBeautifulStore;
    private RelativeLayout relaRewardCoin;
    private RelativeLayout relaCoin;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.activity_seller_center, container, false);
    }

    @Override
    protected void initView() {
        super.initView();
        initTitle();
        tvTitle.setText("商家中心");
        relaAllCenter = (RelativeLayout) getView().findViewById(R.id.relaAllCenter);
        relaBeautifulStore = (RelativeLayout) getView().findViewById(R.id.relaBeautifulStore);
        relaRewardCoin = (RelativeLayout) getView().findViewById(R.id.relaRewardCoin);
        relaCoin = (RelativeLayout) getView().findViewById(R.id.relaCoin);
    }

    @Override
    protected void initData() {
        super.initData();
    }

    @Override
    protected void initEvent() {
        super.initEvent();
        ivBack.setOnClickListener(this);
        relaAllCenter.setOnClickListener(this);
        relaBeautifulStore.setOnClickListener(this);
        relaRewardCoin.setOnClickListener(this);
        relaCoin.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.ivBack:
                getActivity().finish();
                break;
            case R.id.relaAllCenter:
                if(null!= MyApplication.getInstance().getCredentials()&&!"".equals(MyApplication.getInstance().getCredentials())){
                    startAct(SellerManagerOrderActivity.class);
                }else{
                    startAct(SellerManagerLoginActivity.class);
                }
                break;
            case R.id.relaBeautifulStore:
                if(null!= MyApplication.getInstance().getBeautifulCredentials()&&!"".equals(MyApplication.getInstance().getBeautifulCredentials())){
                    startAct(SellerBeautifulStoreOrderActivity.class);
                }else{
                    startAct(SellerBeautifulStoreLoginActivity.class);
                }
                break;
            case R.id.relaRewardCoin:
                break;
            case R.id.relaCoin:
                if(null!=MyApplication.getInstance().getCoinCredentials()&&!"".equals(MyApplication.getInstance().getCoinCredentials())){
                    startAct(SellerCoinStoreOrderActivity.class);
                }else{
                    startAct(SellerCoinStoreLoginActivity.class);
                }
                break;
        }
    }
}
